4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
16 namespace Microsoft
.JScript
{
18 using Microsoft
.JScript
.Vsa
;
20 using System
.Collections
;
21 using System
.Globalization
;
23 using System
.Security
.Permissions
;
25 public abstract class VsaItem
: IVsaItem
{
26 protected string name
;
27 internal string codebase
;
28 internal VsaEngine engine
;
29 protected VsaItemType type
;
30 protected VsaItemFlag flag
;
31 protected bool isDirty
;
33 internal VsaItem(VsaEngine engine
, string itemName
, VsaItemType type
, VsaItemFlag flag
){
42 internal virtual void CheckForErrors(){
45 internal virtual void Close(){
49 internal virtual void Compile(){}
52 internal virtual Type
GetCompiledType(){
53 // only code items have a compiled type
57 public virtual bool IsDirty
{
58 [PermissionSetAttribute(SecurityAction
.LinkDemand
, Name
= "FullTrust")]
60 if (this.engine
== null)
61 throw new VsaException(VsaError
.EngineClosed
);
64 [PermissionSetAttribute(SecurityAction
.LinkDemand
, Name
= "FullTrust")]
66 if (this.engine
== null)
67 throw new VsaException(VsaError
.EngineClosed
);
72 [PermissionSetAttribute(SecurityAction
.LinkDemand
, Name
= "FullTrust")]
73 public virtual Object
GetOption(String name
){
74 if (this.engine
== null)
75 throw new VsaException(VsaError
.EngineClosed
);
76 if (0 == String
.Compare(name
, "codebase", StringComparison
.OrdinalIgnoreCase
))
78 throw new VsaException(VsaError
.OptionNotSupported
);
81 public virtual String Name
{
82 [PermissionSetAttribute(SecurityAction
.LinkDemand
, Name
= "FullTrust")]
84 if (this.engine
== null)
85 throw new VsaException(VsaError
.EngineClosed
);
88 [PermissionSetAttribute(SecurityAction
.LinkDemand
, Name
= "FullTrust")]
90 if (this.engine
== null)
91 throw new VsaException(VsaError
.EngineClosed
);
92 if (this.name
== value)
94 if (!this.engine
.IsValidIdentifier(value))
95 throw new VsaException(VsaError
.ItemNameInvalid
);
96 foreach (IVsaItem item
in this.engine
.Items
){
97 if (item
.Name
.Equals(value))
98 throw new VsaException(VsaError
.ItemNameInUse
);
102 this.engine
.IsDirty
= true;
106 internal virtual void Remove(){
110 internal virtual void Reset(){}
112 internal virtual void Run(){}
114 [PermissionSetAttribute(SecurityAction
.LinkDemand
, Name
= "FullTrust")]
115 public virtual void SetOption(String name
, Object
value){
116 if (this.engine
== null)
117 throw new VsaException(VsaError
.EngineClosed
);
118 if (0 == String
.Compare(name
, "codebase", StringComparison
.OrdinalIgnoreCase
))
119 this.codebase
= (string)value;
121 throw new VsaException(VsaError
.OptionNotSupported
);
123 this.engine
.IsDirty
= true;
126 public VsaItemType ItemType
{
127 [PermissionSetAttribute(SecurityAction
.LinkDemand
, Name
= "FullTrust")]
129 if (this.engine
== null)
130 throw new VsaException(VsaError
.EngineClosed
);